<style scoped>
  .deleteDocument {
    margin-right: 0.5vw;
    padding: 0 15px;
    background-color: white;
    height: 95vh;
    position: relative;
  }
  .deleteDocument_top{
    display: flex;
    padding-top: 15px;
    white-space:nowrap;
  }
  .t_content{
    margin: 0 8px 0 12px;
    padding-top: 3px;
    display: inline-block;
    }
    .t_content1{
      padding-top: 3px;
      margin: 0 6px 0 0;
    }
  .deleteDocument input:focus{
    outline: none;
    border: 1px solid #017aff;
  }
  .inp{
    border: 1px solid #dbdbdb;
    border-radius: 3px;
    height: 30px;
    padding: 0 15px;
  }
  .inp2{
    width: 155px;
  }
  .inp1{
    width: 400px;
  }
  .inp3{
    width: 60px;
    margin-right: 10px;
  }
  .inp4{
    width: 90px;
    margin-left: -1px;
  }
  .inp5{
    width: 150px;
    margin:0 0 0 16px;
  }
  .a_color{
    color: #017aff;
  }
  .deleteDocument_c{
    display: flex;
    width: 100%;
    height: 88%;
    margin-top: 20px;
    border-top: 2px solid #f4f4f4;
  }
  .content1{
    width: 30%;
    border-right: 2px solid #f4f4f4;
    padding-right: 10px;
  }
  .content2{
    width: 70%;
    /* height: 100%; */
    padding-left: 10px;
  }
  .content1_1{
    display: flex;
    margin: 12px 0;
    overflow: hidden;
  }
  .c_button{
    width: 35px;
    height: 30px;
    margin:0 0 0 -1px;
    /* padding:4px 6px 0 0; */
    background: #dbdbdb;
    font-size: 13px;
    border: 0px solid #dbdbdb;
    outline: none;
  }
  .hand{
        cursor: pointer;
  }
  .c2{
    display: flex;
    height: 40px;
    margin-top: 10px;
    flex-wrap: nowrap;
    justify-content: space-between;
  }
  .c2_2{
    display: flex;
    /* margin-left: 115px; */
    height: 40px;
  }
  .c2_1{
    display: flex;
    height: 40px;
  }
  .c2_2 p{
    margin:4px 16px 0 0;
  }
  .check{
    width: 90px;
    height: 40px;
    border: 1px solid #d3cdcd;
    border-radius: 5px;
    padding: 8px 0 0 7px;
  }
  .c2_button{
    height: 25px;
    margin: 8px 5px 0 35px;
  }
  .c2_button1{
    height: 25px;
    margin: 8px 5px 0 0;
  }
  .content2_1{
    margin-top: 3px;
  }
  .date_1{
    margin: 3px 6px 0 0;
  }
  .footView span{
    float: left;
    margin-right: 48px;
    line-height: 6vh;
    font-size: 14px;
  }
  .footView span i{
    margin-right: 5px;
  }

  /* .popup{
    width:400px;height:200px;position:absolute;top:50%;left:50%;border:1px solid black
  } */
  /* .popup{
    width: 400px;
    height: 200px;
    border: 1px solid #dbdbdb;
    box-shadow: 0 2px 2px 2px #dbdbdb;
    z-index: 999;
    position: absolute;
    left: 50%;
    top: 50%;
    margin:-100px 0 0 -200px;
    background: white;
  }
  .popup_t{
    display: flex;
    justify-content: space-between;
    width: 100%;
    height: 40px;
    background: rgb(244, 244, 244);
    padding: 8px 15px;
  }
  .popup_t p{
    font-weight: 700;
  }
  .popup_c{
    padding: 8px 15px;
  }
  .popup_button{
    margin: 5px 0 0 0;
    width: 94%;
    height: 30px;
    padding:0 10px;
    border: 1px solid#dbdbdb;
    border-radius: 3px;
  }
  .popup_b{
    margin: 10px 0 0 0;
    padding-left: 230px;
  } */

</style>

<style>
  .deleteDocument .el-input__icon{
    line-height: 30px;
  }
  .deleteDocument .deleteDocument_top .sty .el-input__inner{
    height: 30px;
    width: 100px;
  }
  .deleteDocument .deleteDocument_top .ph .el-input__inner{
    height: 30px;
    width: 160px;
  }
  .deleteDocument .deleteDocument_top .ph .el-date-editor.el-input,.deleteDocument .deleteDocument_top .ph .el-date-editor.el-input__inner{
    width: 160px;
  }
  .deleteDocument .c_b .el-button{
    padding: 0;
  }
  .deleteDocument .content1_1 .el-input{
    width: 223px;
    margin-left: 10px;
  }
  .deleteDocument .content1_1 .el-input__inner{
    height: 30px;
  }
  .deleteDocument .c2_2 .check{
  margin: 0 16px 0 0;
  width: 70px;
  height: 30px;
  padding: 3px 0 0 7px;
}

.deleteDocument .c2_2 .el-button{
  width: 40px;
}
.deleteDocument .c2 .el-button{
  margin: 0 10px 0 0;
}
</style>


<template>
  <div class="deleteDocument">
    
    <div class="deleteDocument_top">
      <p class="t_content">货号</p>
      <input class="inp inp2" type="text" v-model="kindsNumber">
    </div>
    
    <div class="deleteDocument_c">
      <div class="content1">
        <div class="content1_1">
          <el-button @click="subtractClick"><i class="el-icon-remove-outline"></i> 减标</el-button>
        </div>
        <div class="c_tab">
          <el-table 
            :data="tableData1" 
            style="width: 100%" 
            highlight-current-row 
            height="81vh" 
            :header-cell-style="{background:'#f4f4f4',padding:0,height:'40px'}" 
            :cell-style="{padding:0,height:'36px'}" 
            @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="50"></el-table-column>
            <el-table-column type="index" label="序号" width="50"></el-table-column>
            <el-table-column prop="showCode" label="RFID" width="80"></el-table-column>
            <el-table-column prop="kindsNumber" label="货号"></el-table-column>
            <el-table-column label="数量" width="60">1</el-table-column>
            <el-table-column prop="sellingPrice" label="售价" width="80"></el-table-column>
          </el-table>
        </div>
      </div>

      <div class="content2">
        <div class="c2">
          <div class="c2_1">
            <el-button @click="search" type="primary" icon="el-icon-search">查询</el-button>
            <el-button @click="dele" icon="el-icon-delete">删除</el-button>
          </div>

          <div class="c2_2">
            <p>单据序号：{{sequence}}</p>
          </div>
        </div>

        <div class="content2_1">
          <el-table
            id="outTable"
            :data="tableData2"
            style="width: 100%"
            height="81vh"
            highlight-current-row
            :header-cell-style="{background:'#f4f4f4',padding:0,height:'40px'}"
            :cell-style="{padding:0,height:'36px'}"
            @selection-change="handleSelectionChangeRight">
            <el-table-column type="selection" width="60"></el-table-column>
            <el-table-column type="index" label="序号" width="50"></el-table-column>
            <template v-for="i in tableHead" >
              <el-table-column
                :prop="i.prop"
                :label="i.label"
                :width="i.width"
                :key="i.prop">
              </el-table-column>
            </template>
          </el-table>
        </div>
      </div>
    </div>
  </div>
</template>


<script>
import footView from '../../components/FootView'

import { sequenceRfidList, inputQuery, removeOrderInput, outQuery, removeOrderOut, subtract, removeRfidInput, factoryOutSubtract, removeRfidOutPut } from '../../network/manufacturer'
import { getInputInquire, deleteInput, inSubtract, inEmpty, RfidList, deleteInputAffirm } from '../../network/customerInputTotal'
import { getOutInquire, deleteOut, deleteOutAffirm, outSubtract, outEmpty } from '../../network/customerOutTotal'
import { getSellInquire, deleteSell, deleteSellAffirm, settleAccountsStatus } from '../../network/sellTotal'
import { getBarCode } from '../../network/manufacturer'
import { getSize } from '../../network/size'
import { getBranded } from '../../network/branded'
import { getTwoInfoBySequence, del } from '../../network/customerAllocationTotal'
import { select, deleteOrder } from '../../network/customerOrderTotal'
import { orderQuery, remove, empty } from '../../network/manufacturerOrder'
import { getManufacturer } from '../../network/manufacturer'
import {getCustomerTransfer,DeleteTransfer} from '../../network/customerTransfer'

export default {
  name: 'deleteDocument',
  data(){
    return{
      Str:'',
      kindsNumber: '',
      type: '',
      sequence: '',
      tableHead: [],
      tableData1: [],
      tableData2: [],
      allData: [],
      selectedList: [],

      no: '',
      warehouseNo: '',

      jxQuarter: document.cookie.match(RegExp('jxQuarter'+'=([^;]+)'))[1],

      affirm: false,
      settleAccount: null,
      receiptsNumber: ''
    }
  },
  created(){
    let min = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes()
    let sec = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds()
    let strRandom = (Math.random().toString(36).substring(2,7))//随机字符串
    console.log(strRandom + min + sec) //随机字符串加时间      不重复随机字符串
    this.Str = strRandom + min + sec//需求为关闭页面后重新进来 更换随机数
    // console.log(this.$route.query.sequence)
    this.type = this.$route.query.type
    this.sequence = this.$route.query.sequence
    this.getTableData()
  },
  components: {
    footView
  },
  methods: {
    getTableData(){
      this.allData = []
      this.tableData1 = []
      this.tableData2 = []
      switch (Number(this.type)) {
        case 1:
          // 厂进
          this.tableHead = [
            {
              prop: 'sequence',
              label: '厂进序号',
              width: '160'
            },{
              prop: 'receiptsNumber',
              label: '单据号',
              width: '160'
            },{
              prop: 'manufacturerName',
              label: '厂商',
              width: '100'
            },{
              prop: 'kindsNumber',
              label: '货号',
              width: '160'
            },{
              prop: 'colorNameNo',
              label: '色码',
              width: '100'
            },{
              prop: 'sum',
              label: '数量',
              width: '80'
            },{
              prop: 'sellingPrice',
              label: '售价',
              width: '100'
            },{
              // 售价*金额
              prop: 'sellingPriceMoney',
              label: '售价金额',
              width: '120'
            },{
              prop: 'sellingPriceOne',
              label: '售价1',
              width: '100'
            },{
              prop: 'sellingPriceTwo',
              label: '售价2',
              width: '100'
            },{
              prop: 'sellingPriceThree',
              label: '售价3',
              width: '100'
            },{
              prop: 'sellingPriceFour',
              label: '售价4',
              width: '100'
            },{
              prop: 'purchaseTime',
              label: '进货日期',
              width: '160'
            },{
              prop: 'remark',
              label: '备注',
              width: '160'
            },{
              prop: 'cooperateWay',
              label: '配货方式',
              width: '120'
            },{
              prop: 'warehouseNo',
              label: '仓库编号',
              width: '120'
            },{
              prop: 'operator',
              label: '操作员',
              width: '120'
            },{
              prop: 'enteringTime',
              label: '录入时间',
              width: '120'
            }
          ]
          inputQuery(JSON.stringify({
            sequence: this.sequence,
            pageData: {
              page: 1,
              limit: 999
            }
          })).then(res => {
            if (res.data.data && res.data.data.resultList) {
              let obj = res.data.data.resultList[0]
              this.allData = obj.detailVOList || []
              getManufacturer({no:obj.manufacturerName,limit:99999}).then(r => {
                this.allData.forEach(e => {
                  e.manufacturerName = r.data.data[0].name || ''
                })
                this.$forceUpdate()
              })
              this.allData.forEach(e => {
                e.colorNameNo = e.colorSize
                e.operator = obj.operator
                e.purchaseTime = obj.purchaseTime.slice(0,10)
                e.knInfo = e.kindsNumber
                e.kindsNumber = e.knInfo.kindsNumber
                e.sellingPriceOne = e.knInfo.sellingPriceOne
                e.sellingPriceTwo = e.knInfo.sellingPriceTwo
                e.sellingPriceThree = e.knInfo.sellingPriceThree
                e.sellingPriceFour = e.knInfo.sellingPriceFour
              })
              this.tableData2 = this.allData
              this.no = this.tableData2[0].manufacturerNo
            }
          })
          sequenceRfidList({
            sequence: this.sequence,
            type: 1
          }).then(res => {
            this.tableData1 = res.data.data
          })
          break;
        case 2:
          // 厂退
          this.tableHead = [
            {
              prop: 'sequence',
              label: '厂退序号',
              width: '160',
              isShow: true
            },{
              prop: 'odd',
              label: '单据号',
              width: '160',
              isShow: true
            },{
              prop: 'manufacturerName',
              label: '厂商',
              width: '180',
              isShow: true
            },{
              prop: 'kindsNumber',
              label: '货号',
              width: '160',
              isShow: true
            },{
              prop: 'colorNameNo',
              label: '色码',
              width: '80',
              isShow: true
            },{
              prop: 'sum',
              label: '数量',
              width: '80',
              isShow: true
            },{
              prop: 'sellingPrice',
              label: '售价',
              width: '100',
              isShow: true
            },{
              // 售价*金额
              prop: 'sellingPriceMoney',
              label: '售价金额',
              width: '120',
              isShow: true
            },{
              prop: 'sellingPriceOne',
              label: '售价1',
              width: '100',
              isShow: true
            },{
              prop: 'sellingPriceTwo',
              label: '售价2',
              width: '100',
              isShow: true
            },{
              prop: 'sellingPriceThree',
              label: '售价3',
              width: '100',
              isShow: true
            },{
              prop: 'sellingPriceFour',
              label: '售价4',
              width: '100',
              isShow: true
            },{
              prop: 'purchaseTime',
              label: '进货日期',
              width: '160',
              isShow: true
            },{
              prop: 'remark',
              label: '备注',
              width: '160',
              isShow: true
            },{
              prop: 'cooperateWay',
              label: '配货方式',
              width: '120',
              isShow: true
            },{
              prop: 'warehouseNo',
              label: '仓库编号',
              width: '120',
              isShow: true
            },{
              prop: 'operator',
              label: '操作员',
              width: '120',
              isShow: true
            },{
              prop: 'enteringTime',
              label: '录入时间',
              width: '120',
              isShow: true
            }
          ]
          outQuery(JSON.stringify({
            sequence: this.sequence,
            pageData: {
              page: 1,
              limit: 9999
            }
          })).then(res => {
            let obj = res.data.data.resultList[0]
            this.allData = obj.detailVOList || []
            getManufacturer({no:obj.manufacturerName,limit:99999}).then(r => {
              this.allData.forEach(e => {
                e.manufacturerName = r.data.data[0].name || ''
              })
              this.$forceUpdate()
            })
            this.allData.forEach(e => {
              e.colorNameNo = e.colorSize
              e.operator = obj.operator
              e.purchaseTime = obj.purchaseTime.slice(0,10)
              e.knInfo = e.kindsNumber
              e.kindsNumber = e.knInfo.kindsNumber
              e.sellingPriceOne = e.knInfo.sellingPriceOne
              e.sellingPriceTwo = e.knInfo.sellingPriceTwo
              e.sellingPriceThree = e.knInfo.sellingPriceThree
              e.sellingPriceFour = e.knInfo.sellingPriceFour
            })
            this.tableData2 = this.allData
            this.no = this.tableData2[0].manufacturerNo
          })
          sequenceRfidList({
            sequence: this.sequence,
            type: 2
          }).then(res => {
            this.tableData1 = res.data.data
          })
          break;
        case 3:
          // 客进
          this.tableHead = [
            {
              prop: 'sequence',
              label: '客进序号',
              width: '160',
              isShow: true
            },{
              prop: 'name',
              label: '客户',
              width: '100',
              isShow: true
            },{
              prop: 'kindsNumber',
              label: '货号',
              width: '160',
              isShow: true
            },{
              prop: 'commodityName',
              label: '品名',
              width: '160',
              isShow: true
            },{
              prop: 'sellingPrice',
              label: '售价',
              width: '100',
              isShow: true
            },{
              prop: 'discount',
              label: '折数',
              width: '50',
              isShow: true
            },{
              prop: 'onePrice',
              label: '单价',
              width: '100',
              isShow: true
            },{
              prop: 'sum',
              label: '数量',
              width: '80',
              isShow: true
            },{
              prop: 'money',
              label: '金额',
              width: '120',
              isShow: true
            },{
              prop: 'accessoryName',
              label: '附件',
              width: '140',
              isShow: true
            },{
              prop: 'purchaseTime',
              label: '客进日期',
              width: '160',
              isShow: true
            },{
              prop: 'remark',
              label: '备注',
              width: '200',
              isShow: true
            },{
              prop: 'warehouseNo',
              label: '仓库编号',
              width: '80',
              isShow: true
            },{
              prop: 'operator',
              label: '操作员',
              width: '120',
              isShow: true
            },{
              prop: 'entryTime',
              label: '录入时间',
              width: '160',
              isShow: true
            },
          ]
          getInputInquire({
            inputSequence:this.sequence,
            limit: 999,
            page: 1
          }).then(res => {
            if (res.data.data) {
              this.allData = res.data.data.inputInquireInfoList
              this.allData.forEach(e => {
                e.Sequence = e.sequence
              })
              this.tableData2 = this.allData
              this.no = this.tableData2[0].no
              this.warehouseNo = this.tableData2[0].warehouseNo

              this.affirm = res.data.data.inputInquireTotalList[0].affirm
            }
          })
          RfidList({
            sequence: this.sequence,
            type: 1
          }).then(res => {
            this.tableData1 = res.data.data
            // this.tableData1.forEach(e => {
            //   e.number = 1
            // })
          })
          break;
        case 4:
          // 客退
          this.tableHead = [
            {
              prop: 'sequence',
              label: '客退序号',
              width: '160',
              isShow: true
            },{
              prop: 'no',
              label: '客户编号',
              width: '100',
              isShow: true
            },{
              prop: 'name',
              label: '客户简称',
              width: '100',
              isShow: true
            },{
              prop: 'kindsNumber',
              label: '货号',
              width: '160',
              isShow: true
            },{
              prop: 'colorSize',
              label: '色码',
              width: '100',
              isShow: true
            },{
              prop: 'commodityName',
              label: '品名',
              width: '160',
              isShow: true
            },{
              prop: 'sellingPrice',
              label: '售价',
              width: '100',
              isShow: true
            },{
              prop: 'discount',
              label: '折数',
              width: '50',
              isShow: true
            },{
              prop: 'onePrice',
              label: '单价',
              width: '100',
              isShow: true
            },{
              prop: 'sum',
              label: '数量',
              width: '80',
              isShow: true
            },{
              prop: 'money',
              label: '金额',
              width: '120',
              isShow: true
            },{
              prop: 'outTime',
              label: '客退日期',
              width: '160',
              isShow: true
            },{
              prop: 'remark',
              label: '备注',
              width: '200',
              isShow: true
            },{
              prop: 'entryTime',
              label: '录入时间',
              width: '160',
              isShow: true
            }
          ]
          getOutInquire({
            outSequence:this.sequence,
            limit: 99999,
            page: 1
          }).then(res => {
            this.allData = res.data.data.outInquireInfoList
            this.allData.forEach(e => {
              e.Sequence = e.sequence
            })
            this.tableData2 = this.allData
            this.no = this.tableData2[0].no
            this.warehouseNo = this.tableData2[0].warehouseNo

            this.affirm = res.data.data.outInquireTotalList[0].affirm
          })
          RfidList({
            sequence: this.sequence,
            type: 2
          }).then(res => {
            this.tableData1 = res.data.data
          })
          break;
        case 5:
          // 客销
          this.tableHead = [
            {
              prop: 'sequence',
              label: '客销序号',
              width: '160',
              isShow: true
            },{
              prop: 'business',
              label: '业务',
              width: '100',
              isShow: true
            },{
              prop: 'name',
              label: '客户',
              width: '100',
              isShow: true
            },{
              prop: 'area',
              label: '地区',
              width: '100',
              isShow: true
            },{
              prop: 'kindsNumber',
              label: '货号',
              width: '160',
              isShow: true
            },{
              prop: 'commodityName',
              label: '品名',
              width: '160',
              isShow: true
            },{
              prop: 'sellingPrice',
              label: '售价',
              width: '100',
              isShow: true
            },{
              prop: 'discount',
              label: '折数',
              width: '50',
              isShow: true
            },{
              prop: 'onePrice',
              label: '单价',
              width: '100',
              isShow: true
            },{
              prop: 'sum',
              label: '数量',
              width: '80',
              isShow: true
            },{
              prop: 'tagPrice',
              label: '吊牌金额',
              width: '120',
              isShow: true
            },{
              prop: 'money',
              label: '金额',
              width: '120',
              isShow: true
            },{
              prop: 'sellTime',
              label: '客销日期',
              width: '160',
              isShow: true
            },{
              prop: 'remark',
              label: '备注',
              width: '200',
              isShow: true
            },{
              prop: 'operator',
              label: '操作员',
              width: '120',
              isShow: true
            },{
              prop: 'brandedName',
              label: '品牌',
              width: '160',
              isShow: true
            },{
              prop: 'styleNumber',
              label: '款号',
              width: '140',
              isShow: true
            },{
              prop: 'entryTime',
              label: '录入时间',
              width: '160',
              isShow: true
            },
          ]
          getSellInquire({
            sellSequence:this.sequence,
            limit: 99999,
            page: 1
          }).then(res => {
            this.allData = res.data.data.sellInquireInfoList
            this.allData.forEach(e => {
              e.Sequence = e.sequence
            })
            this.tableData2 = this.allData

            this.affirm = res.data.data.sellInquireTotalList[0].affirm
            this.receiptsNumber = res.data.data.sellInquireTotalList[0].receiptsNumber
          })
          settleAccountsStatus({sequence: this.sequence}).then(res => {
            this.settleAccount = res.data.data
          })
          break;
        case 6:
          // 客户配货
          this.tableHead = [
            {
              prop: 'allocationCargoSequence',
              label: '配货序号'
            },{
              prop: 'no',
              label: '客户编号'
            },{
              prop: 'kindsNumber',
              label: '货号'
            },{
              prop: 'number',
              label: '数量'
            },{
              prop: 'allocationCargoTime',
              label: '配货日期'
            },{
              prop: 'affirm',
              label: '确认'
            },{
              prop: 'remark',
              label: '备注'
            }
          ]
          getTwoInfoBySequence({
            customerNo: this.$route.query.no,
            sequence: this.sequence
          }).then(res => {
            if (res.data.code == 200) {
              let list = []
              res.data.data.forEach(e => {
                getBranded({name:e.brandedName, limit: 9999}).then(rr => {
                    // 品牌公司查条码规律详情
                  getBarCode({company: rr.data.data[0].brandedCompany}).then(res => {
                    let manufacturerBarCode = {}
                    manufacturerBarCode = res.data.data[0]
                    
                    getSize({kind:manufacturerBarCode.sizeKindId,limit:9999}).then(r => {
                      let c = e.colorNo
                      let knList = []
                      r.data.data.forEach(f => {
                        if (manufacturerBarCode.styleColorSize) {
                          // 型尺色

                          if (manufacturerBarCode.styleColor) {
                            // 款号与尺码之间有 - 

                            if (manufacturerBarCode.colorSize) {
                              // 色号与尺码之间有 - 
                              if (e[f.relevanceSize]) {
                                knList.push({
                                  kindsNumber:`${e.styleNumber}-${f.size}-${c}`,
                                  number:e[f.relevanceSize]
                                })
                              }
                              
                            } else {
                              // 色号与尺码之间没有 -  
                              if (e[f.relevanceSize]) {
                                knList.push({
                                  kindsNumber:`${e.styleNumber}-${f.size}${c}`,
                                  number:e[f.relevanceSize]
                                })
                              }
                              
                            }
                          } else {
                            // 款号与尺码之间没有 - 

                            if (manufacturerBarCode.colorSize) {
                              // 色号与尺码之间有 - 
                              if (e[f.relevanceSize]) {
                                knList.push({
                                  kindsNumber:`${e.styleNumber}${f.size}-${c}`,
                                  number:e[f.relevanceSize]
                                }) 
                              } 
                              
                            } else {
                              // 色号与尺码之间没有 - 
                              if (e[f.relevanceSize]) {
                                knList.push({
                                  kindsNumber:`${e.styleNumber}${f.size}${c}`,
                                  number:e[f.relevanceSize]
                                })
                              }
                              
                            }
                          }
                        } else {
                          // 型色尺

                          if (manufacturerBarCode.styleColor) {
                            // 款号与颜色之间有 - 

                            if (manufacturerBarCode.colorSize) {
                              // 色号与尺码之间有 -  
                              if (e[f.relevanceSize]) {
                                knList.push({
                                  kindsNumber:`${e.styleNumber}-${c}-${f.size}`,
                                  number:e[f.relevanceSize]
                                })
                              }
                              
                            } else {
                              // 色号与尺码之间没有 - 
                              if (e[f.relevanceSize]) {
                                knList.push({
                                  kindsNumber:`${e.styleNumber}-${c}${f.size}`,
                                  number:e[f.relevanceSize]
                                })
                              } 
                              
                            }
                          } else {
                            // 款号与颜色之间没有 - 

                            if (manufacturerBarCode.colorSize) {
                              // 色号与尺码之间有 -  
                              if (e[f.relevanceSize]) {
                                knList.push({
                                  kindsNumber:`${e.styleNumber}${c}-${f.size}`,
                                  number:e[f.relevanceSize]
                                })
                              }
                              
                            } else {
                              // 色号与尺码之间没有 - 
                              if (e[f.relevanceSize]) {
                                knList.push({
                                  kindsNumber:`${e.styleNumber}${c}${f.size}`,
                                  number:e[f.relevanceSize]
                                }) 
                              }
                              
                            }
                          }
                        }
                      })
                      // console.log(knList)
                      for (const i of knList) {
                        i.allocationCargoSequence = this.sequence
                        i.no = this.$route.query.no
                        i.affirm = this.$route.query.affirm
                        i.allocationCargoTime = this.$route.query.allocationCargoTime
                        i.remark = this.$route.query.remark
                      }
                      list = list.concat(knList)
                      // console.log(list)
                      this.allData = list
                      this.tableData2 = this.allData
                    })
                  })
                })
                
              })
            }
          })
          break;
        case 7:
          // 客户订货
          this.tableHead = [
            {prop:'orderSalesSequence',label:'客户订货序号',width:'140'},
            {prop:'receiptsNumber',label:'单据号',width:'120'},
            {prop:'customerNo',label:'客户编号',width:''},
            {prop:'customerName',label:'客户简称',width:''},
            {prop:'kindsNumber',label:'货号',width:'160'},
            {prop:'commodityName',label:'品名',width:''},
            {prop:'sellingPrice',label:'售价',width:''},
            {prop:'discount',label:'折数',width:''},
            {prop:'onePrice',label:'单价',width:''},
            {prop:'number',label:'数量',width:''},
            {prop:'money',label:'金额',width:''}
          ]
          select({orderSequence: this.sequence}).then(res => {
            this.allData = res.data.data.customerOrderVOListInfo
            // this.allData.forEach(e => {
            //   e.Sequence = e.orderSalesSequence
            // })
            this.tableData2 = this.allData
          })
          break;
        case 8:
          // 厂商订货
          this.tableHead = [
            {prop:'orderSalesSequence',label:'厂订序号',width:'140'},
            {prop:'receiptsNumber',label:'单号',width:'120'},
            {prop:'manufacturerNo',label:'厂商编号',width:''},
            {prop:'manufacturerName',label:'厂商简称',width:''},
            {prop:'kindsNumber',label:'货号',width:'140'},
            {prop:'commodityName',label:'品名',width:''},
            {prop:'sellingPrice',label:'售价',width:''},
            {prop:'discount',label:'折数',width:'50'},
            {prop:'onePrice',label:'单价',width:''},
            {prop:'number',label:'数量',width:''},
            {prop:'money',label:'金额',width:''},
            {prop:'orderTimeShort',label:'订货日期',width:'120'}
          ]
          orderQuery(JSON.stringify({
            orderSalesSequence: this.sequence,
            totalWay: 0
          })).then(res => {
            this.allData = res.data.data[this.sequence].manufacturerOrderInfoOneVOList
            
            this.tableData2 = this.allData
          })
          break;
        case 9:
          // 厂退
          break;
        case 11:
          //客调
          this.tableHead = [
            {prop:'kindsNumber',label:'货号',width:'140'},
            {prop:'calloutCustomer',label:'调出客户',width:'140'},
            {prop:'number',label:'数量',width:''},
            {prop:'fold',label:'调入',width:''},
            {prop:'foldName',label:'调入客户',width:''},
            {prop:'transferCargoT',label:'调货日期',width:''},
            {prop:'callout',label:'调出',width:''},
            {prop:'sequenceStatus',label:'状态',width:'50'},
            {prop:'transferCargoIntention',label:'调货意向',width:''},
            {prop:'operator',label:'操作员',width:''}
          ]
          getCustomerTransfer({transferCargoSequence:this.sequence}).then(res=>{
            // console.log(res.data)
            this.allData = res.data.data.customerTransferCargoInfoList
            this.tableData2 = this.allData
          })
      }
    },
    // 减标
    subtractClick(){
      if (!this.subRFID.length) {
        this.$alert('请先点击选择一条数据再进行减标操作', '', {
          confirmButtonText: '确定'
        })
        return
      }

      if (this.subRFID.length == this.tableData1.length) {
        switch (Number(this.type)) {
          case 1:
            removeRfidInput({
              sequence:this.sequence,flagToken:this.Str
            }).then(res => {
              if (res.data.code == 200) {
                this.tableData1 = []
                this.tableData2 = []
                this.allData = []
                this.$message({
                  message: '减标成功',
                  type: 'success'
                })
              } else {
                this.$message.error('减标失败')
              }
            })
            break;
          case 2:
            removeRfidOutPut({
              sequence:this.sequence,flagToken:this.Str
            }).then(res => {
              if (res.data.code == 200) {
                this.tableData1 = []
                this.tableData2 = []
                this.allData = []
                this.$message({
                  message: '减标成功',
                  type: 'success'
                })
              } else {
                this.$message.error('减标失败')
              }
            })
            break;
          case 3:
            inEmpty({
              sequence:this.sequence,
              customerNo: this.no,
              warehouseNo: this.warehouseNo,
              flagToken:this.Str
            }).then(res => {
              if (res.data.code == 200) {
                this.tableData1 = []
                this.tableData2 = []
                this.allData = []
                this.$message({
                  message: '减标成功',
                  type: 'success'
                })
              } else {
                this.$message.error('减标失败')
              }
            })
            break;
          case 4:
            outEmpty({
              sequence:this.sequence,
              customerNo: this.no,
              warehouseNo: this.warehouseNo,
              flagToken:this.Str
            }).then(res => {
              if (res.data.code == 200) {
                this.tableData1 = []
                this.tableData2 = []
                this.allData = []
                this.$message({
                  message: '减标成功',
                  type: 'success'
                })
              } else {
                this.$message.error('减标失败')
              }
            })
            break;
        }
        
      } else {
        let d = {}
        switch (Number(this.type)) {
          case 1:
            // 厂进
            d = {
              manufacturerDTO: {
                inputSequence: this.sequence
              },
              rfidList: this.subRFID,
              flagToken:this.Str
            }

            // console.log(d)
            // return
            subtract(JSON.stringify(d)).then(res => {
              if (res.data.code == 200) {
                this.getTableData()
                this.$message({
                  message: '减标成功',
                  type: 'success'
                })
              } else {
                this.$message.error('减标失败')
              }
            })
            break;
          case 2:
            // 厂退
            d = {
              manufacturerDTO: {
                inputSequence: this.sequence
              },
              rfidList: this.subRFID,
              flagToken:this.Str
            }

            // console.log(d)
            // return
            factoryOutSubtract(JSON.stringify(d)).then(res => {
              if (res.data.code == 200) {
                this.getTableData()
                this.$message({
                  message: '减标成功',
                  type: 'success'
                })
              } else {
                this.$message.error('减标失败')
              }
            })
            break;
          case 3:
            d = {
              customerDTO: {
                sequence: this.sequence,
                customerNo: this.no,
                warehouseNo: this.warehouseNo
              },
              rfidList: this.subRFID,
              flagToken:this.Str
            }
            // console.log(d)

            inSubtract(JSON.stringify(d)).then(res => {
              if (res.data.code == 200) {
                this.getTableData()
                this.$message({
                  message: '减标成功',
                  type: 'success'
                })
              } else {
                this.$message.error('减标失败')
              }
            })
            break;
          case 4:
            d = {
              customerDTO: {
                sequence: this.sequence,
                customerNo: this.no,
                warehouseNo: this.warehouseNo
              },
              rfidList: this.subRFID,
              flagToken:this.Str
            }

            outSubtract(JSON.stringify(d)).then(res => {
              if (res.data.code == 200) {
                this.getTableData()
                this.$message({
                  message: '减标成功',
                  type: 'success'
                })
              } else {
                this.$message.error('减标失败')
              }
            })
            break;
        }
        
      }
    },
    search(){
      if (!this.kindsNumber) {
        this.tableData2 = this.allData
        return
      }
      this.tableData2 = []
      this.allData.forEach(e => {
        if (e.kindsNumber == this.kindsNumber) {
          this.tableData2.push(e)
        }
      })
    },
    dele(){
      // console.log(Boolean(this.affirm))
      if (!this.selectedList.length) {
        this.$alert('请选择数据再进行删除操作', '', {
          confirmButtonText: '确定'
        })
        return
      }

      switch (Number(this.type)) {
        case 1:
          // 厂进
          let kindsNumberNumberMap1 = {}
          this.selectedList.forEach(e => {
            kindsNumberNumberMap1[e.kindsNumber] = e.sum
          })
          let d1 = {
            inputSequence: this.sequence,
            manufacturerNo: this.no,
            kindsNumberNumberMap: this.selectedList.length == this.allData.length ? {} : kindsNumberNumberMap1,
            flagToken: this.Str
          }
          removeOrderInput(JSON.stringify(d1)).then(res => {
            if (res.data.code == 200) {
              this.$message({
                message: '删除成功',
                type: 'success'
              })
              this.getTableData()
              // this.$store.commit('minusNav', '厂商进货删单')
              // this.$router.push({path:'/input/vendor_stock_query',query:{d:Math.ceil(Math.random()*1000)}})
              // this.$store.commit('addNav',{label:'厂商进货查询',name:'vendor_stock_query'})
            } else {
              this.$message.error('删除失败')
            }
          })
          break;
        case 2:
          // 厂退
          let kindsNumberNumberMap2 = {}
          this.selectedList.forEach(e => {
            kindsNumberNumberMap2[e.kindsNumber] = e.sum
          })
          let d2 = {
            inputSequence: this.sequence,
            manufacturerNo: this.no,
            kindsNumberNumberMap: this.selectedList.length == this.allData.length ? {} : kindsNumberNumberMap2,
            flagToken: this.Str
          }
          removeOrderOut(JSON.stringify(d2)).then(res => {
            if (res.data.code == 200) {
              this.$message({
                message: '删除成功',
                type: 'success'
              })
              this.getTableData()
              // this.$store.commit('minusNav', '厂商退货删单')
              // this.$router.push({path:'/input/vendor_return_query',query:{d:Math.ceil(Math.random()*1000)}})
              // this.$store.commit('addNav',{label:'厂商退货查询',name:'vendor_return_query'})
            } else {
              this.$message.error('删除失败')
            }
          })
          break;
        case 3:
          // 客进
          let isSelectAll3 = this.selectedList.length == this.allData.length ? 1 : 0
          this.selectedList.forEach(e => {
            e.isSelectAll = isSelectAll3;
            e.flagToken = this.Str
          })
          if (this.affirm) {
            deleteInputAffirm(JSON.stringify(this.selectedList)).then(res => {
              if (res.data.code == 200) {
                this.$message({
                  message: '删除成功',
                  type: 'success'
                })
                this.getTableData()
                // this.$store.commit('minusNav', '客户进货删单')
                // this.$router.push({path:'/customer/client_stock_query',query:{d:Math.ceil(Math.random()*1000)}})
                // this.$store.commit('addNav',{label:'客户进货查询',name:'client_stock_query'})
              } else {
                this.$message.error('删除失败')
              }
            })
          } else {
            deleteInput(JSON.stringify(this.selectedList)).then(res => {
              if (res.data.code == 200) {
                this.$message({
                  message: '删除成功',
                  type: 'success'
                })
                this.getTableData()
                // this.$store.commit('minusNav', '客户进货删单')
                // this.$router.push({path:'/customer/client_stock_query',query:{d:Math.ceil(Math.random()*1000)}})
                // this.$store.commit('addNav',{label:'客户进货查询',name:'client_stock_query'})
              } else {
                this.$message.error('删除失败')
              }
            })
          }
          
          break;
        case 4:
          // 客退
          let isSelectAll4 = this.selectedList.length == this.allData.length ? 1 : 0
          this.selectedList.forEach(e => {
            e.isSelectAll = isSelectAll4;
            e.flagToken = this.Str
          })
          if (this.affirm) {
            deleteOutAffirm(JSON.stringify(this.selectedList)).then(res => {
              if (res.data.code == 200) {
                this.$message({
                  message: '删除成功',
                  type: 'success'
                })
                this.getTableData()
                // this.$store.commit('minusNav', '客户退货删单')
                // this.$router.push({path:'/customer/client_return_query',query:{d:Math.ceil(Math.random()*1000)}})
                // this.$store.commit('addNav',{label:'客户退货查询',name:'client_return_query'})
              } else {
                this.$message.error('删除失败')
              }
            })
          } else {
            deleteOut(JSON.stringify(this.selectedList)).then(res => {
              if (res.data.code == 200) {
                this.$message({
                  message: '删除成功',
                  type: 'success'
                })
                this.getTableData()
                // this.$store.commit('minusNav', '客户退货删单')
                // this.$router.push({path:'/customer/client_return_query',query:{d:Math.ceil(Math.random()*1000)}})
                // this.$store.commit('addNav',{label:'客户退货查询',name:'client_return_query'})
              } else {
                this.$message.error('删除失败')
              }
            })
          }
          
          break;
        case 5:
          // 客销
          let isSelectAll5 = this.selectedList.length == this.allData.length ? 1 : 0
          this.selectedList.forEach(e => {
            e.isSelectAll = isSelectAll5;
            e.flagToken = this.Str
          })
          if (this.affirm) {
            deleteSellAffirm(JSON.stringify(this.selectedList)).then(res => {
              if (res.data.code == 200) {
                this.$message({
                  message: '删除成功',
                  type: 'success'
                })
                this.getTableData()
                if (this.settleAccount) {
                  this.$message.info(`单号:${this.inputSequence}请前往店铺销售查询页面查看`)
                }
                // this.$store.commit('minusNav', '客户销货删单')
                // this.$router.push({path:'/customer/client_sales_query',query:{d:Math.ceil(Math.random()*1000)}})
                // this.$store.commit('addNav',{label:'客户销货查询',name:'client_sales_query'})
              } else {
                this.$message.error('删除失败')
              }
            })
          } else {
            deleteSell(JSON.stringify(this.selectedList)).then(res => {
              if (res.data.code == 200) {
                this.$message({
                  message: '删除成功',
                  type: 'success'
                })
                this.getTableData()
                // this.$store.commit('minusNav', '客户销货删单')
                // this.$router.push({path:'/customer/client_sales_query',query:{d:Math.ceil(Math.random()*1000)}})
                // this.$store.commit('addNav',{label:'客户销货查询',name:'client_sales_query'})
              } else {
                this.$message.error('删除失败')
              }
            })
          }
          
          break;
        case 6:
          // 客户配货
          this.selectedList.forEach(e=>{
            e.flagToken = this.Str
          })
          del(JSON.stringify(this.selectedList)).then(res => {
            if (res.data.code == 200) {
              this.$message({
                message: '删除成功',
                type: 'success'
              })
              this.getTableData()
              // this.$store.commit('minusNav', '客户配货删单')
              // this.$router.push({path:'/customer/client_distribution',query:{d:Math.ceil(Math.random()*1000)}})
              // this.$store.commit('addNav',{label:'客户配货查询',name:'client_distribution'})
            } else {
              this.$message.error('删除失败')
            }
          })
          break;
        case 7:
          // 客户订货
          let isSelectAll7 = this.selectedList.length == this.allData.length ? 1 : 0
          this.selectedList.forEach(e => {
            e.sequence = e.orderSalesSequence
            e.isSelectAll = isSelectAll7
            e.sum = e.number
            e.flagToken = this.Str
          })
          deleteOrder(JSON.stringify(this.selectedList)).then(res => {
            if (res.data.code == 200) {
              this.$message({
                message: '删除成功',
                type: 'success'
              })
              this.getTableData()
              // this.$store.commit('minusNav', '客户订货删单')
              // this.$router.push({path:'/order/client_order_goods_query',query:{d:Math.ceil(Math.random()*1000)}})
              // this.$store.commit('addNav',{label:'客户订货查询',name:'client_order_goods_query'})
            } else {
              this.$message.error('删除失败')
            }
          })
          break;
        case 8:
          // 厂商订货
          if (this.selectedList.length == this.tableData2.length) {
            empty({sequence: this.sequence,flagToken: this.Str}).then(res => {
              // console.log(res)
              if (res.data.code == 200) {
                this.$message.success("删除成功")
                this.tableData2 = []
              } else {
                this.$message.error("删除失败")
              }
            })
          } else {
            let kindsNumberList = []
            this.selectedList.forEach(e => {
              kindsNumberList.push(e.kindsNumber)
            })
            remove({
              sequence: this.sequence,
              kindsNumberList
            }).then(res => {
              // console.log(res)
              if (res.data.code == 200) {
                this.$message.success("删除成功")
                this.getTableData()
              } else {
                this.$message.error("删除失败")
              }
            })
          }
          break;
        case 9:
          // 厂退
          break;
        case 10:
          // 厂退
          break;
        case 11:
          //客户调货
          let list = []
          this.selectedList.forEach(ele=>{
            list.push({kindsNumber:ele.kindsNumber,transferCargoSequence:ele.transferCargoSequence,number:ele.number,flagToken:this.Str})
          })
          // console.log(list)
          DeleteTransfer(JSON.stringify(list)).then(res=>{
            // console.log(res)
            if(res.data.code == 200){
              this.$message.success('删除成功')
              this.getTableData()
            }else{
              this.$message.error('删除失败')
            }
          })
          break;
      }
    },
    handleSelectionChange(e){
      this.subRFID = e
    },
    handleSelectionChangeRight(e){
      this.selectedList = e
    }
  },
  watch: {
    $route(a,b){
      this.type = this.$route.query.type
      this.sequence = this.$route.query.sequence
      this.getTableData()
    }
  }
}
</script>

